package com.ygqh.baby.mapper;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.ygqh.baby.ao.ProductStatus;
import com.ygqh.baby.ao.QueryInfo;
import com.ygqh.baby.model.CheckStockModel;
import com.ygqh.baby.model.StockModel;
import com.ygqh.baby.model.StockVo;
import com.ygqh.baby.model.YgStockModel;
import com.ygqh.baby.po.YgSku;
import com.ygqh.baby.po.YgStock;
import com.ygqh.baby.po.YgStockExample;

public interface YgStockMapper {
	int countByExample(YgStockExample example);

	int deleteByExample(YgStockExample example);

	int deleteByPrimaryKey(Long id);

	int insert(YgStock record);

	int insertSelective(YgStock record);

	List<YgStock> selectByExample(YgStockExample example);

	YgStock selectByPrimaryKey(Long id);

	int updateByExampleSelective(@Param("record") YgStock record, @Param("example") YgStockExample example);

	int updateByExample(@Param("record") YgStock record, @Param("example") YgStockExample example);

	int updateByPrimaryKeySelective(YgStock record);

	int updateByPrimaryKey(YgStock record);

	int countSuper(@Param("q") String q, @Param("groupId") Long groupId, @Param("productName") String productName, @Param("productCode") String productCode,
			@Param("skuCode") String skuCode, @Param("amount") Long amount, @Param("isPre") Boolean isPre);

	List<YgStock> selectSuper(@Param("queryInfo") QueryInfo queryInfo, @Param("q") String q, @Param("groupId") Long groupId,
			@Param("productName") String productName, @Param("productCode") String productCode, @Param("skuCode") String skuCode, @Param("amount") Long amount,
			@Param("isPre") Boolean isPre);

	int reduceStock(@Param("stocks") List<YgStock> stocks);

	Boolean validateStockNum(@Param("skuId") Long skuId, @Param("quantity") Long quantity);

	int backStock(@Param("stockList") List<YgStock> stockList);

	int updateBatch(@Param("stockList") List<YgStock> stockList);

	int updateBatchByTask(@Param("stockList") List<YgStock> stockList);

	List<CheckStockModel> checkStock();

	List<YgSku> findByProductId(@Param("productId") Long productId);

	YgStock selectLastUpdate(@Param("updateBy") String updateBy);

	int countSuperV2(@Param("q") String q, @Param("productStatus") ProductStatus productStatus, @Param("productName") String productName,
			@Param("productCode") String productCode, @Param("skuCode") String skuCode, @Param("amount") Long amount, @Param("supplierId") Long supplierId,
			@Param("isPre") Boolean isPre, @Param("isSync") Boolean isSync,@Param("adminProductName") String adminProductName,@Param("barCode") String barCode);

	List<StockModel> selectSuperV2(@Param("queryInfo") QueryInfo queryInfo, @Param("q") String q, @Param("productStatus") ProductStatus productStatus,
			@Param("productName") String productName, @Param("productCode") String productCode, @Param("skuCode") String skuCode, @Param("amount") Long amount,
			@Param("supplierId") Long supplierId, @Param("isPre") Boolean isPre, @Param("isSync") Boolean isSync,@Param("adminProductName") String adminProductName,@Param("barCode") String barCode);

	List<StockModel> selectProductStock(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("amount") Long amount);

	List<StockModel> selectSkuStockByProduct(@Param("pCodeList") List<String> pCodeList);

	List<YgStockModel> selectByProductCode(@Param("productCode") String productCode);

	List<YgStockModel> selectByProductCodes(@Param("productCodes") List<String> productCodes);

	List<StockVo> selectStockVoBySkuCodes(@Param("skuCodes") String... skuCodes);

	List<StockVo> selectStockVoByProductCodes(@Param("productCodes") String... productCodes);

    List<String> getSkuCodeListForSyncStock();
}
